package cn.bb.springboothello;

import cn.bb.springboothello.filter.SecondFilter;
//import cn.bb.springboothello.listener.SecondListener;
import cn.bb.springboothello.servlet.SecondServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.*;
import org.springframework.context.annotation.Bean;

/*
* springboot整合servlet方式2
* 整合filter方式2
* 整合listener方式2
* */
@SpringBootApplication
public class App2 {

	public static void main(String[] args) {
		SpringApplication.run(App2.class,args);
	}
	/*注册servlet*/
	@Bean
	public ServletRegistrationBean getServletRegistrationBean(){
		ServletRegistrationBean bean = new ServletRegistrationBean(new SecondServlet());
		bean.addUrlMappings("/second");
		return bean;
	}
	/*注册filter*/
	@Bean
	public FilterRegistrationBean getFilterRegistrationBean(){
		FilterRegistrationBean bean = new FilterRegistrationBean(new SecondFilter());
		bean.addUrlPatterns("/second");
		return bean;
	}
	/*注册listener*/
	/*@Bean
	public ServletListenerRegistrationBean getServletListenerRegistrationBean(){
		ServletListenerRegistrationBean bean = new ServletListenerRegistrationBean(new SecondListener());
		return  bean;
	}*/
}

